<template>
  <!--信息导入-->
  <div class="app-container" :style="{height: tableHeight + 130 + 'px'}" style="overflow-y: auto">
    <!--<el-form class="jc_search_wrap" v-model="searchList">
      <label>选择文件</label>
      <el-input type="file" id="file2"></el-input>
      <span>文件大小不可超过30M</span>
    </el-form>-->
    <el-tabs v-model="activeName" @tab-click="handleClick">
        <!--文件一---------------------------------------------------------------------------------------------------------->
        <el-tab-pane v-for="(item, index) in file" :label="item.sheetName" :name="String(index)" :key="index">
          <!--<el-table :data="item.crystalMessages" :height="tableHeight-200" border fit highlight-current-row class="jc_table_wrap" ref="multipleTable">
            <el-table-column  type="index"  label='编号' width="70" fixed>
            </el-table-column>
            <el-table-column label='箱号' fixed>
              <template scope="scope">
                {{scope.row.no}}
              </template>
            </el-table-column>
            <el-table-column label="单晶编号"  width="230" fixed>
              <template scope="scope">
                {{scope.row.crystalNo}}
              </template>
            </el-table-column>
            <el-table-column label="规格" width="130">
              <template scope="scope">
                {{scope.row.norms}}
              </template>
            </el-table-column>
            <el-table-column label='托号'>
              <template scope="scope">
                {{scope.row.orderNumber}}
            </template>
            </el-table-column>
            <el-table-column label='客户类别'>
              <template scope="scope">
                {{scope.row.customerType}}
            </template>
            </el-table-column>
            &lt;!&ndash;<el-table-column label='厂牌'>
              <template scope="scope">
                {{scope.row.factoryCard}}
            </template>
            </el-table-column>&ndash;&gt;
            <el-table-column label="单晶长度(mm)" width="120">
              <template scope="scope">
                {{scope.row.crystalLength}}
              </template>
            </el-table-column>
            <el-table-column label="崩损长度(mm)" width="120">
              <template scope="scope">
                {{scope.row.chipLength}}
              </template>
            </el-table-column>
            <el-table-column label="单晶出厂重量(kg)" width="150">
              <template scope="scope">
                {{scope.row.factoryWeight}}
              </template>
            </el-table-column>
            <el-table-column label="称重(kg)">
              <template scope="scope">
                {{scope.row.weight}}
              </template>
            </el-table-column>
            <el-table-column label="斜(mm)">
              <template scope="scope">
                {{scope.row.oblique}}
              </template>
            </el-table-column>
            <el-table-column label="晶体灰皮(mm)" width="120">
              <template scope="scope">
                {{scope.row.crystalGrey}}
              </template>
            </el-table-column>
            <el-table-column label="晶片灰皮(mm)" width="120">
              <template scope="scope">
                {{scope.row.chipGrey}}
              </template>
            </el-table-column>
            <el-table-column label="线痕(mm)" width="120">
              <template scope="scope">
                {{scope.row.scratch}}
              </template>
            </el-table-column>
          </el-table>
        --></el-tab-pane>
      </el-tabs>
    <h4>硅棒汇总</h4>
    <el-table :data="summaryData" border fit highlight-current-row class="jc_table_wrap" ref="multipleTable">
      <el-table-column label='物料名称'>
        <template scope="scope">
          {{scope.row.materialName}}
        </template>
      </el-table-column>
      <el-table-column label="总箱数">
        <template scope="scope">
          {{scope.row.totalNo}}
        </template>
      </el-table-column>
     <!-- <el-table-column label="直径">
        <template scope="scope">
          {{scope.row.description}}
        </template>
      </el-table-column>-->
      <el-table-column label="单晶长度(mm)">
        <template scope="scope">
          {{scope.row.totalLength}}
        </template>
      </el-table-column>
      <el-table-column label="崩损长度(mm)">
        <template scope="scope">
          {{scope.row.totalChiplength}}
        </template>
      </el-table-column>
      <el-table-column label="单晶出厂重量(kg)">
        <template scope="scope">
          {{scope.row.totalFactoryweight}}
        </template>
      </el-table-column>
      <el-table-column label="称重(kg)">
        <template scope="scope">
          {{scope.row.totalWeight}}
        </template>
      </el-table-column>
      <el-table-column label="斜(mm)">
        <template scope="scope">
          {{scope.row.totalOblique}}
        </template>
      </el-table-column>
      <el-table-column label="晶体灰皮(mm)">
        <template scope="scope">
          {{scope.row.totalCrystalgrey}}
        </template>
      </el-table-column>
      <el-table-column label="晶片灰皮(mm)">
        <template scope="scope">
          {{scope.row.totalChipgrey}}
        </template>
      </el-table-column>
      <el-table-column label="线痕(mm)">
        <template scope="scope">
          {{scope.row.totalScratch}}
        </template>
      </el-table-column>
    </el-table>
    <el-form class="jc_search_wrap" v-model="searchList">
      <label>备注</label>
      <el-input type="textarea"></el-input>
    </el-form>
    <div slot="footer" class="dialog-footer" style="display:block;text-align: center;margin-top: 10px;">
      <!--<el-button type="primary" @click="">检验数据</el-button>-->
      <el-button type="primary" @click="confirm">确定</el-button>
      <el-button @click="closeDialog">关闭</el-button>
    </div>
    <div class="el-loading-mask el-loading-fade-enter-to" v-loading.body="isShow" element-loading-text="请稍等，拼命加载中" v-show="isShow">
    </div>
  </div>
</template>

<script>

  import * as Silicon from "../../../api/silicon_rod/silicon";

  export default {
    components: {

    },
    data() {
      return {
        searchList: {},
        list: [],
        activeName: '0',
        total:0,
        multipleSelection: [],
        file: [],
        summaryData: [],
        pl88: '',
        list01: [],
        excelId: '',
        isShow: false,
      }

    },
    filters: {
      statusFilter(status) {
        const statusMap = {
          published: 'success',
          draft: 'gray',
          deleted: 'danger'
        };
        return statusMap[status]
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      fetchData(p=1) {
        this.file = this.$route.query.file;

        if(this.file !== undefined) {
          if(this.file.length > 0) {

            this.summaryData.push(this.file[0].crystalTotal);
            this.excelId = this.file[0].crystalTotal.excelId;
          }
        }

      },
      handleClick(tab, event) {
        this.summaryData= [];
        switch(tab.index) {
          case tab.index: this.summaryData.push(this.file[tab.index].crystalTotal);
        }
      },
      confirm() {
        this.$confirm('确定提交该条数据?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            this.isShow= true;
          Silicon.confirm(this.excelId).then(data => {
            this.errorInfo = data;
            this.$message({
              type: 'success',
              message: data.msg
            });
            this.isShow= false;
            this.$router.push({path: '/silicon_rod/siliconInfor_import'})
          }).catch((data) => {
              $('.el-message').css('display','none');
            this.isShow= false;
            this.$router.push({path: '/silicon_rod/siliconInfor_import',query: {errorInfo: data}})
          })
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消提交'
          });
        });
      },
      closeDialog() {
        this.$router.push({path: '/silicon_rod/siliconInfor_import'})
      },
    },
    computed: {
      tableHeight() {
        const filterHeight = 28;
        var tableHeight = this.getTableHeight(filterHeight);
        return tableHeight;
      },
      tableHeight_top() {
        const filterHeight = 28;
        var tableHeight = this.getTableHeight(filterHeight);
        return tableHeight/2-10;
      },
      tableHeight_bottom() {
        const filterHeight = 100;
        var tableHeight = this.getTableHeight(filterHeight);
        return tableHeight/2-10;
      },
    }
  }
</script>
